package com.estudos.init;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;



public class Inicializar implements WebApplicationInitializer {

	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {
		AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
		ctx.register(WebAppConfig.class);
		
		ctx.setServletContext(servletContext);
		Dynamic serv = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
		serv.addMapping("/");
		
		serv.setLoadOnStartup(1);
         
		System.out.println("aaaaaaaaa Inicializou o Servlet");
		
		
	}

}
